package nrrg.zhujuxing.application.learnscala

object traitTest {
  def main(args: Array[String]): Unit = {
    val student = new student
    student.sayHi()
    student.play()
    val student2: person = new person
    student2.sayHi()
  }

  class person(val name: String = "person", var age: Int = 18) {
    def sayHi(): Unit = {
      println("hi")
    }
  }

  trait young {
    var age: Int
    val name: String = "young"

    def play(): Unit = {
      println("playing")
    }

    def date(): Unit
  }

  class student extends person with young{
    override val name: String = "student"
    override def date(): Unit = {
      println("dating")
    }

    override def sayHi(): Unit = {
      super.sayHi()
      println(s"hi from student $name")
    }

  }

}
